<!--
 * @Author: daidai
 * @Date: 2022-03-01 15:27:58
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2022-05-07 11:24:14
 * @FilePath: \web-pc\src\pages\big-screen\view\indexs\right-center.vue
-->
<template>
  <div v-if="pageflag" :class="{ 'overflow-y-auto': true }" class="right_center_wrap beautify-scroll-def">
    <vue3-seamless-scroll :hover="true"
                          :isWatch="true"
                          :limitScrollNum="7"
                          :list="list"
                          :step="0.4"
                          :wheel="true">
      <ul class="right_center ">
        <li v-for="(item, i) in list" :key="i" class="right_center_item">
          <span class="orderNum">{{ i + 1 }}</span>
          <div class="inner_right">
            <div class="dibu"></div>
            <div class="flex">
              <div class="info">
                <span class="labels ">电梯名称：</span>
                <span class="contents zhuyao"> {{ item.elevatorName }}</span>
              </div>
              <div class="info">
                <span class="labels">告警类型：</span>
                <span class="contents warning"> 
                  <span v-for="item2 in elevator_event_type" v-show="item2 && item2.dictValue == item.eventType"
                        :key="item2.dictCode">
                    {{ item2.dictLabel }}
                  </span>
                </span>
              </div>
            </div>


            <div class="flex">
              <div class="info time">
                <span class="labels">时间：</span>
                <span class="contents" style="font-size:12px"> {{ item.reportTime }}</span>
              </div>

            </div>
            <div class="flex">

              <div class="info">
                <span class="labels">报警内容：</span>
                <span :class="{ warning: item.remark }" class="contents ciyao"> {{ JSON.parse(item.remark)?.data || "无" }}</span>
              </div>
            </div>
          </div>
        </li>
      </ul>
    </vue3-seamless-scroll>
  </div>
  <Reacquire v-else style="line-height:200px" @onclick="getData" />

</template>

<script>
import { realTimeWarning } from "@/api";
import { getDicts } from "@/api/system/dict/data";

export default {
  data() {
    return {
      timer: null,
      list: [],
      pageflag: true,
      defaultOption: {
        step: 4.4,
        hoverStop: true,
        openWatch: true,
        direction: 1,
        limitMoveNum: 5,
        singleHeight: 240,
        singleWidth: 0,
        waitTime: 3000
      },
      elevator_event_type: null
    };
  },
  created() {
    getDicts("elevator_event_type").then(res => {
      this.elevator_event_type = res.data;
    });
  },

  mounted() {
    this.getData();
  },
  methods: {
    getData() {
      this.pageflag = true;
      // this.pageflag =false
      realTimeWarning({
        pageNum: 1,
        pageSize: 20
      }).then(res => {
        this.list = res.data;
        // this.timer = setTimeout(() => {
        //   clearTimeout(this.timer);
        //   this.defaultOption.step = 3;
        // }, 10000);
      });
    }

  },
  unmounted() {
    console.log("right-bottom unmound");
    window.clearTimeout(this.timer);
  }
};
</script>
<style scoped>
@import "@/assets/css/variable.scss";

.right_center {
  width: 100%;
  height: 100%;

  .right_center_item {
    display: flex;
    align-items: center;
    justify-content: center;
    height: auto;
    padding: 10px;
    font-size: 14px;
    color: #fff;

    .orderNum {
      margin: 0 20px 0 -20px;
    }


    .inner_right {
      position: relative;
      height: 100%;
      width: 400px;
      flex-shrink: 0;
      line-height: 1.5;

      .dibu {
        position: absolute;
        height: 2px;
        width: 104%;
        background-image: url("../../assets/img/zuo_xuxian.png");
        bottom: -12px;
        left: -2%;
        background-size: cover;
      }
    }

    .info {
      margin-right: 10px;
      display: flex;
      align-items: center;

      .labels {
        flex-shrink: 0;
        font-size: 12px;
        color: rgba(255, 255, 255, 0.6);
      }

      .zhuyao {
        color: $primary-color;
        font-size: 15px;
      }

      .ciyao {
        color: rgba(255, 255, 255, 0.8);
      }

      .warning {
        color: #E6A23C;
        font-size: 15px;
      }
    }

  }
}

.right_center_wrap {
  overflow: hidden;
  width: 100%;
  height: 250px;
}

.overflow-y-auto {
  overflow-y: auto;
}
</style>